package wonder.com.chinaerweima;



import android.content.SharedPreferences;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//    editor写入的时候使用
        setContentView(R.layout.activity_main);
        SharedPreferences sharedPreferences=getSharedPreferences("text",MODE_PRIVATE);
        SharedPreferences.Editor   editor=sharedPreferences.edit();
        editor.putInt("textInt",100);
        editor.putString("textString","哈哈");
//      commit是一个方法 commit()
        editor.commit();
//       getInt的时候用 sharedPreferences
        int a=sharedPreferences.getInt("textInt",0);
        String b=sharedPreferences.getString("textString","你好世界");
        Toast.makeText(this,"读取的配置文件数据"+a+"       "+b,Toast.LENGTH_SHORT).show();
    }
}
